﻿using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.UI;

public class GetText : MonoBehaviour {
    public Text tagert;
    public EncodingType type;
    void Start()
    {
        MCNetSocket.OnRec += (data, count) =>
        {
            switch (type)
            {
                case EncodingType.UTF8:
                    tagert.text = Encoding.UTF8.GetString(data,0,count);
                    break;
                case EncodingType.ASCII:
                    tagert.text = Encoding.ASCII.GetString(data,0, count);
                    break;
                case EncodingType.Unicode:
                    tagert.text = Encoding.Unicode.GetString(data, 0, count);
                    break;
                case EncodingType.BigEndianUnicode:
                    tagert.text = Encoding.BigEndianUnicode.GetString(data, 0, count);
                    break;
                default:
                    
                    break;
            }
            
            
        };
    }
}
public enum EncodingType
{
    UTF8,
    ASCII,
    Unicode,
    BigEndianUnicode

}
